define(["utils"],function(utils){


    var personItem = function(config){
      var _this = this;
      this.itemData = config.itemData;
      this.valueData = this.itemData.value;
      this.group = config.group;

      this.status ="unChecked"; //checked
      this.selector = config.selector;
      this.$el = $("<div class='person-selector-item'></div>");
      this.triangle = $("<span class='person-selector-triangle'></span>");
      this.checkbox = $("<span class='person-selector-checkbox yy-fontawesome'></span>")
      this.text = $("<span class='person-selector-text'>"+this.valueData.userName+"</span>");
      this.$el.append(this.triangle).append(this.checkbox).append(this.text);
      this.$el.bind("click",function(e){
        e.stopPropagation();
        e.preventDefault();
        if(_this.group){
          _this.group.personItemToggle(_this);
        }else{
          _this.selector.leftTree.rootPersonItemToggle(_this);

        }
      });
      if(this.selector.initSelectedPersonData){
        if(this.selector.isInSelectedPersonData(this.itemData)){
          this.checked();
        }
      }

    }

    personItem.prototype={
      checked:function(){
        this.checkbox.addClass("checked");
        this.status = "checked";
      },
      unChecked:function(){
        this.checkbox.removeClass("checked");
        this.status = "unChecked";
      }
    }


    return personItem;
});
